import 'package:appflutter/_13_Animation/image_detail.dart';
import 'package:flutter/material.dart';

main() => runApp(myApp());

class myApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(primaryColor: Colors.blue),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('首页'),
        elevation: 0,
      ),
      body: GridView.builder(
          gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
              crossAxisCount: 2,
              crossAxisSpacing: 8,
              mainAxisSpacing: 8,
              childAspectRatio: 0.75
          ),
          itemBuilder: (context, index) {
            final image_url = 'https://picsum.photos/500/500?random=$index';
            return GestureDetector(
              child: Hero(
                  child: Image.network(image_url, fit: BoxFit.cover,),
                  tag: image_url,
              ),
              onTap: () {
                Navigator.of(context).push(
                PageRouteBuilder(pageBuilder: (context,animate1,animate2){
                  return FadeTransition(
                      child: image_detail_page(image_url),
                    opacity: animate1,
                  );
                })
                );
              },
            );
          }),
    );
  }
}
